#include <QPushButton>
#include <QDebug>
#include <QMenuBar>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "helper.h"
#include <writer.h>
#include <qfont.h>

MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow) {
    ui->setupUi(this);
    this->setWindowTitle("扫雷");
    this->setFixedSize(800, 600);
    QFont btn_font("等线", 12);
    QFont Menu_font("Microsoft YaHei", 12, 75);
    QMenuBar *bar = menuBar();
    setMenuBar(bar);
    QMenu *startMenu = bar->addMenu("· · ·");
    bar->setFont(Menu_font);
    QAction *start = startMenu->addAction("开始游戏");
    QAction *help = startMenu->addAction("帮助");
    QAction *quit = startMenu->addAction("退出");
    startMenu->addSeparator();
    QAction *shiki = startMenu->addAction("猜猜这是啥");
    QPushButton *startbtn = new QPushButton("开     始", this);
    QPushButton *helpbtn = new QPushButton("帮     助", this);
    QPushButton *quitbtn = new QPushButton("退     出", this);
    startbtn->resize(300, 100);
    startbtn->setFont(btn_font);
    startbtn->move(this->width() * 0.5 - startbtn->width() * 0.5, this->height() * 0.35);
    helpbtn->resize(300, 100);
    helpbtn->setFont(btn_font);
    helpbtn->move(this->width() * 0.5 - startbtn->width() * 0.5, this->height() * 0.55);
    quitbtn->resize(300, 100);
    quitbtn->setFont(btn_font);
    quitbtn->move(this->width() * 0.5 - startbtn->width() * 0.5, this->height() * 0.75);
    //-----生成选关界面 保存指针方便操作-----
    chooselevel = new levelchoose;
    connect(startbtn, &QPushButton::clicked, [=]() {
        this->hide();
        chooselevel->show();
    });
    connect(helpbtn, &QPushButton::clicked, [=]() {
        helper *helplist = new helper;
        helplist->show();
    });
    connect(quitbtn, &QPushButton::clicked, [=]() {
        this->close();
    });
    connect(start, &QAction::triggered, [=]() {
        emit startbtn->clicked();
    });
    connect(quit, &QAction::triggered, [=]() {
        emit quitbtn->clicked();
    });
    connect(help, &QAction::triggered, [=]() {
        emit helpbtn->clicked();
    });
    connect(shiki, &QAction::triggered, [=]() {
        writer *Easter_egg = new writer;
        Easter_egg->show();
    });
}

MainWindow::~MainWindow() {
    delete ui;
}
